package com.example.emb.controller;

import com.example.emb.entity.Showworktable;
import com.example.emb.mapper.YeartableMapper;
import com.example.emb.service.GreatWorkService;
import com.example.emb.until.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@Api(tags = "关于优秀作业列表的api")
@RequestMapping("/zjgsEmb/GreatWork")
public class greatWorkController {
    @Autowired
    YeartableMapper yeartableMapper;
    @Autowired
    GreatWorkService greatWorkService;

    @ApiOperation("获得所有年份，使用在优秀作业列表的下拉菜单")
    @GetMapping("/getAllYears")
    private JsonResult<List<Integer>> getAllYears(){
        List<Integer> list=new ArrayList<>();
        list=yeartableMapper.selectAllYears();
        return new JsonResult<List<Integer>>(200,list);
    }

    @ApiOperation("通过优秀作业列表下拉菜单的值来查询优秀作业列表    传入选择的年份和班级类型，如果都没有选那么就上传year=0，classType=-1")
    @GetMapping("/getSelectedGreatWorks")
    private JsonResult<List<Showworktable>> getSelectedGreatWorks(int year,int classType){
        List<Showworktable> list=new ArrayList<>();
        greatWorkService.GetSelectedGreatWork(year,classType);
        return new JsonResult<List<Showworktable>>(200,list);
    }

}
